package com.peng.servlet;

import com.peng.dao.impl.regionDaoImpl;
import com.peng.dao.impl.userDaoImpl;
import com.peng.dao.regionDao;
import com.peng.dao.userDao;
import com.peng.entity.user;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 欧阳欣鹏 on 2018/8/11.
 */
public class RegionFindbyIdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        user u=new user();
        regionDao r=new regionDaoImpl();
       u.setUname(request.getParameter("uname"));
       u.setUphone(request.getParameter("phone"));
       u.setUpassword(request.getParameter("pwd"));
       u.setUprovince(r.findregionid(request.getParameter("province")+"省"));
       u.setUcity(r.findregionid(request.getParameter("city")));
       u.setUcounty(r.findregionid(request.getParameter("area")));
       u.setUaddress(request.getParameter("address"));
       u.setUsex(request.getParameter("usex"));
       u.setOpenid(request.getParameter("openid"));
       u.setCheck(1);
       u.setUtype(5);
       u.setUimage("WaterPurifiersrcmainimages头像");
       u.setUemail(request.getParameter("email"));
        userDao us=new userDaoImpl();
        us.insert(u);
        response.sendRedirect("StaffAddServlet");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }
}
